﻿<section class="well" ng-controller="functionsCtrl">
    <div class="ra-well-title">
        <button type="button" ng-click="saveFixture()" tabindex="-1" class="btn btn-default">Save fixtures</button>
        <button type="button" ng-click="exportExcel()" tabindex="-1" class="btn btn-default">Export to excel</button>
        <button type="button" ng-click="defineClosedItems();open(closeFiWindow)" tabindex="-1" class="btn btn-default">Close fixtures</button>
    </div>

    <form name="gridForm" ng-controller="gridController">
        <div kendo-grid k-options="mainGridOptions" id="grid" class="row"></div>
        <script>
            setTimeout(function () {
                $('#grid > div.k-grid-header > div > table > thead > tr > th > a.k-link').each(function () {
                    $(this).attr('tabindex', -1);
                });
                $(".k-textbox").attr('tabindex', -1);
                $(".k-dropdown").attr('tabindex', -1);
            }, 4000);
        </script>
    </form>
</section>
<div style="visibility:hidden">
    <div kendo-window="closeFiWindow" k-title="'You are going to close the following fixtures'" k-visible="false" k-resizable="false" k-modal="true"
         k-on-open="closeFiWindowvisible = true" k-on-close="closeFiWindowvisible = false" k-width="400" k-height="400">
        <div class="modal-body" ng-controller="dateValidator">
            <div class="form-control" style="height:265px; overflow-y:scroll">
                <p ng-repeat="i in sendList">
                    <a ng-href="{{i.LinkToDemurrage}}" tabindex="-1" target="_blank">
                        {{i.Vessel.Name+' C/P '+getDateString(i.CPDate)}}
                    </a>
                </p>
            </div>
        </div>
        <div class="modal-footer">
            <button type="button" ng-click="closeFiWindow.close();closeFixture();"
                    class=" btn btn-default">
                OK
            </button>
            <button type="button" ng-click="closeFiWindow.close()" class=" btn btn-default">Cancel</button>
        </div>
    </div>
</div>

<script type="text/x-kendo-template" id="template">
    <div kendo-tab-strip id="tabstrip" k-content-urls="[ 'Contest/Template/ownerTab', 'Contest/Template/portsTab', 'Contest/Template/ordersTab' ]" k-animation="false" class="k-widget k-header k-tabstrip" style="min-height: 400px">
        <ul class="k-tabstrip-items k-reset">
            <li class="k-item k-state-default k-first k-tab-on-top k-state-active"><h4>Owner/Charterer</h4></li>
            <li class="k-item k-state-default"><h4>Ports</h4></li>
            <li class="k-item k-state-default k-last"><h4>Orders</h4></li>
        </ul>
    </div>
</script>

<div kendo-window="portsWindow"
     k-width="340" k-height="310" k-visible="false"
     k-content="{ url: 'Contest/Template/portsPopup' }"
     k-on-open="portsWindowvisible = true" k-on-close="portsWindowvisible = false" k-title="false"
     k-resizable="false" k-modal="true">
</div>

<script type="text/x-kendo-template" id="loadPortTemplate">
    <div style="white-space: nowrap; overflow: hidden;" @*ng-show="!loadingPortsWindowvisible"*@
         ng-click="initPopup(dataItem.SelectedLoadingPort,'load', dataItem.Id, dataItem.LoadingPorts, dataItem.SelectedLoad);
         windowCalc(); portsWindow.open()" ng-controller="dateValidator">
        <div ng-controller="setterPopup">
            <div ng-controller="commonCalculator" ng-init="init('load',dataItem.Id, false)">{{dataItem.LoadingPorts[dataItem.SelectedLoadingPort].Name}}</div>
            <div>{{dataItem.LoadingPorts[dataItem.SelectedLoadingPort].ETAMarker}}  {{getDateTimeString(dataItem.LoadingPorts[dataItem.SelectedLoadingPort].ETA_NORTime)}}</div>
            <div>{{dataItem.LoadingPorts[dataItem.SelectedLoadingPort].ETDMarker}}  {{getDateTimeString(dataItem.LoadingPorts[dataItem.SelectedLoadingPort].ETD_ATDTime)}}</div>
            <div>{{dataItem.LoadingPorts[dataItem.SelectedLoadingPort].Chat[dataItem.LoadingPorts[dataItem.SelectedLoadingPort].Chat.length-1].Message}}</div>
        </div>
    </div>

</script>

<script type="text/x-kendo-template" id="dischPortTemplate">
    <div style="white-space: nowrap; overflow: hidden" @*ng-show="!dischargePortsWindowvisible"*@
         ng-click="initPopup(dataItem.SelectedDischargePort,'disc', dataItem.Id, dataItem.DischargePorts, dataItem.SelectedDisch);
         windowCalc(); portsWindow.open()" ng-controller="dateValidator">
        <div ng-controller="commonCalculator" ng-init="init('disch',dataItem.Id, false)">{{dataItem.DischargePorts[dataItem.SelectedDischargePort].Name}}</div>
        <div>{{dataItem.DischargePorts[dataItem.SelectedDischargePort].ETAMarker}}  {{getDateTimeString(dataItem.DischargePorts[dataItem.SelectedDischargePort].ETA_NORTime)}}</div>
        <div>{{dataItem.DischargePorts[dataItem.SelectedDischargePort].ETDMarker}}  {{getDateTimeString(dataItem.DischargePorts[dataItem.SelectedDischargePort].ETD_ATDTime)}}</div>
        <div>{{dataItem.DischargePorts[dataItem.SelectedDischargePort].Chat[dataItem.DischargePorts[dataItem.SelectedDischargePort].Chat.length-1].Message}}</div>
    </div>
</script>

<div kendo-window="layCanWindow"
     k-width="180" k-height="120" k-visible="false"
     k-on-open="layCanWindowvisible = true" k-on-close="layCanWindowvisible = false" k-title="false" k-resizable="false" k-modal="true"
     k-content="{ url: 'Contest/Template/layCan' }">
</div>

<script type="text/x-kendo-template" id="layCanTemplate">

    <div @*ng-show="!layCanWindowvisible"*@ ng-click="initPopupLay(dataItem.LayCan, dataItem.Id); windowCalc(); layCanWindow.open()" ng-controller="dateValidator">
        <div>From:<br />{{getDateString(dataItem.LayCan.FromDate)}}</div>
        <div>To:<br />{{getDateString(dataItem.LayCan.ToDate)}}</div>
    </div>
</script>

<div kendo-window="window"
     k-width="230" k-height="55" k-visible="false"
     k-on-open="Windowvisible = true" k-on-close="Windowvisible = false" k-title="false" k-resizable="false"
     k-modal="true" k-content="{ url: 'Contest/Template/dateTimePopup' }">
</div>

<script type="text/x-kendo-template" id="VOTemplate">
    <div @*ng-show="!VOWindowvisible"*@ ng-click="initPopupDate('VOD', dataItem.VoyageOrderDate, dataItem.Id); windowCalc(); window.open();" class="text-center">
        <input type="checkbox" id="VOCheckbox" tabindex="-1" ng-checked="dataItem.VoyageOrderDate != undefined" onclick="return false">
    </div>
</script>

<script type="text/x-kendo-template" id="LOTemplate">
    <div ng-show="!LOWindowvisible" ng-click="initPopupDate('LOD', dataItem.LoadingOrderDate, dataItem.Id); windowCalc(); window.open()" class="text-center">
        <input type="checkbox" id="LOCheckbox" tabindex="-1" ng-checked="dataItem.LoadingOrderDate != undefined" onclick="return false">
    </div>
</script>

<script type="text/x-kendo-template" id="DOTemplate">
    <div ng-show="!DOWindowvisible" ng-click="initPopupDate('DO', dataItem.DischargeOrderDate, dataItem.Id); windowCalc(); window.open()" class="text-center">
        <input type="checkbox" id="DOCheckbox" tabindex="-1" ng-checked="dataItem.DischargeOrderDate != undefined" onclick="return false">
    </div>
</script>

<script type="text/x-kendo-template" id="BLTemplate">
    <div ng-show="!BLWindowvisible" ng-click="initPopupDate('BOD', dataItem.BillOfLadenDate, dataItem.Id); windowCalc(); window.open()" class="text-center">
        <input type="checkbox" id="BLCheckbox" tabindex="-1" ng-checked="dataItem.BillOfLadenDate != undefined" onclick="return false">
    </div>
</script>

<script type="text/x-kendo-template" id="LoITemplate">
    <div ng-show="!LoIWindowvisible" ng-click="initPopupDate('LoI', dataItem.LetterOfIndemnityDate, dataItem.Id); windowCalc(); window.open()" class="text-center">
        <input type="checkbox" id="LoICheckbox" tabindex="-1" ng-checked="dataItem.LetterOfIndemnityDate != undefined" onclick="return false">
    </div>
</script>

<script type="text/x-kendo-template" id="FITemplate">
    <div ng-show="!FIWindowvisible" ng-click="initPopupDate('FID', dataItem.FreightInvoiceDate, dataItem.Id); windowCalc(); window.open()" class="text-center">
        <input type="checkbox" id="FICheckbox" tabindex="-1" ng-checked="dataItem.FreightInvoiceDate != undefined" onclick="return false">
    </div>
</script>

<script type="text/x-kendo-template" id="demurrageTemplate">
    <a ng-href="{{dataItem.LinkToDemurrage}}" tabindex="-1" target="_blank">
        <div class="text-center {{dataItem.DemurrageStatus.style}}" ng-controller="dateValidator">
            {{dataItem.DemurrageStatus.value}}
            <br ng-show="dataItem.DemurrageAmount!=null" />{{toFixedAmount(dataItem.DemurrageAmount)}}
            <br ng show="dataItem.DemurrageAgreedDate!=null"/>{{getDateString(dataItem.DemurrageAgreedDate)}}
        </div>
    </a>
</script>

<script type="text/x-kendo-template" id="CityTemplate">
    <div class="text-center">
        <input type="checkbox" tabindex="-1" ng-checked="dataItem.CommissionInvoiceDate!=null" ng-disabled="dataItem.CommissionInvoiceDate==null"
               onclick="window.open('#=WorkspaceUrl#', '_blank'); return false">
    </div>
</script>

<script type="text/x-kendo-template" id="VesselTemplate">
    <a ng-href="{{dataItem.WorkspaceUrl}}" tabindex="-1" target="_blank">{{dataItem.VesselName}}</a>
</script>

<script type="text/x-kendo-template" id="VoyageTemplate">
    <a ng-href="{{dataItem.WorkspaceUrl}}" tabindex="-1" target="_blank">{{dataItem.VoyageRef}}</a>
</script>

<script type="text/x-kendo-template" id="OwnerTemplate">
    <a ng-href="{{dataItem.Owner.CrmUrl}}" tabindex="-1" target="_blank">{{dataItem.Owner.Name}}</a>
</script>

<script type="text/x-kendo-template" id="ChartenerTemplate">
    <a ng-href="{{dataItem.Charterer.CrmUrl}}" tabindex="-1" target="_blank">{{dataItem.Charterer.Name}}</a>
</script>

<script type="text/x-kendo-template" id="CloseTemplate">
    <div class="text-center">
        <input type="checkbox" tabindex="-1" id="#=Id#">
    </div>
</script>

<script type="text/x-kendo-template" id="ChangedTemplate">
    <div class="text-center">
        <input type="checkbox" tabindex="-1" ng-model="dataItem.changed" class="centered" ng-init="restoreChanged('Changed'+dataItem.Id)" id="Changed#=Id#" ng-disabled="true">
    </div>
</script>

<script type="text/x-kendo-template" id="ComissionTemplate">
    <div class="text-center">
        <input type="checkbox" tabindex="-1" ng-disabled="true" ng-checked="dataItem.CollectCommission == true">
    </div>
</script>

<div kendo-window="CPWindow"
     k-width="180" k-height="55" k-visible="false"
     k-on-open="CPWindowvisible = true" k-on-close="CPWindowvisible = false" k-title="false" k-resizable="false"
     k-modal="true" k-content="{ url: 'Contest/Template/CP' }">
</div>

<script type="text/x-kendo-template" id="CPTemplate">

    <div @*ng-show="!CPWindowvisible"*@ ng-click="initPopupDate('CP', dataItem.CPDate, dataItem.Id); windowCalc();
         CPWindow.open()" style="height:60px;width:80px;vertical-align: middle; display: table-cell;" ng-controller="dateValidator">
        {{getDateString(dataItem.CPDate)}}
    </div>
</script>

<script type="text/x-kendo-template" id="brokeForTemplate">
    #if(BrokeForChartrer){#
    Charterer#}else if(BrokeForOwner) {#
    Owner#}#
</script>
